package com.example.springmvc.handler;

import com.example.springmvc.pojo.Dept;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.ModelAttribute;

/**
 * @Description: 全局数据预处理
 * @Author: lijiewei
 * @Date: 2020/7/15$ 22:20$
 */
@ControllerAdvice
public class DataPreHandler {

    @InitBinder("u")
    public void user(WebDataBinder binder) {
        binder.setFieldDefaultPrefix("u.");
    }

    @InitBinder("d")
    public void dept(WebDataBinder binder) {
        binder.setFieldDefaultPrefix("d.");
    }
}
